package WaiBao;

import java.util.Arrays;

public class JiaoXingLe {
    public static void main(String[] args) {
        String[] name = {"求伯君(班长)","李少卿(组织委员)", "小李(学习委员)","王志文(文艺委员)", "王凯", "张长岭", "陈勇", "邓丽君", "李耀宇", "严祥", "张太爱", "许可",
                "王祖蓝", "李富贵", "小胖", "王一凡", "王战", "王一博", "王珂", "郭辉", "李慧超", "李大咏", "萧敬腾", "李德伦", "赵超华", "金庸", "包贝尔", "郑凯",
                "马天宇", "焦馨乐(学生)"};//考生本人:焦馨乐(学生)
        int[] age = {20, 21, 20, 19, 18, 20, 19, 20, 19, 19, 18, 18, 18, 20, 20, 20, 18, 18,21, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位考生本人：年龄:20

        double[] lvjian1 = {84, 72, 86, 84, 77, 69, 78, 84, 81, 80, 91, 87, 75, 79, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 84, 95};
        double[] lvjian2 = {86, 64, 75, 66, 68, 67, 68, 68, 80, 70, 80, 77, 66, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 81, 68, 81, 96};
        double[] lvjian3 = {84, 77, 80, 75, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 75, 89, 95};


        double maomao1 ;//代表每个学生的总分
        double maomao2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            maomao1 = lvjian1[i] + lvjian2[i] + lvjian3[i];
//            maomao2 = (maomao1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + maomao1);
//            System.out.println(name[i] + "的平均分为:" + maomao2);
//        }


        double mogu1 = 0, mogu2 = 0;
        double[] heihu = new double[30];
//        for (int i = 0; i < 30; i++) {
//            mogu1 = lvjian1[i] +lvjian2[i] + lvjian3[i];
//            mogu2 = (mogu1 * 1.0) / 3;
//            heihu[i] = mogu2;
//        }
//
//        for (int i = 0; i <  heihu.length - 1; i++) {
//            for (int j = 0; j < heihu.length - i - 1; j++) {
//                if (heihu[j] <heihu[j + 1]) {
//                    double tep =heihu[j];
//                    heihu[j] =heihu[j + 1];
//                    heihu[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( heihu[i]);
//        }



        double ysl1 = 0, ysl2 = 0, ysl3 = 0;//计算每门课的平均分
        double bolan1 = 0,bolan2 = 0,bolan3 = 0;//计算每门课标准差
        double guyu1 = 0,guyu2 = 0,guyu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < lvjian1.length; i++) {
            he += lvjian1[i];
        }
        ysl1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +ysl1);
        double Sum = 0;
        for (int i = 0; i < lvjian2.length; i++) {
            Sum += lvjian2[i];
        }
        ysl2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + ysl2);
        double sum = 0;
        for (int i = 0; i < lvjian3.length; i++) {
            sum += lvjian3[i];
        }
        ysl3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +ysl3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < lvjian1.length; i++) {
            c1 += (lvjian1[i] - ysl1) * (lvjian1[i] - ysl1);
        }
        bolan1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + bolan1);
        for (int i = 0; i <lvjian2.length; i++) {
            c2 += (lvjian2[i] - ysl2) * (lvjian2[i] -ysl2);
        }
        bolan2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +bolan2);

        for (int i = 0; i <lvjian3.length; i++) {
            c3 += (lvjian3[i] - ysl3) * (lvjian3[i] - ysl3);
        }
        bolan3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +bolan3);
//
////
        Arrays.sort(lvjian1);
        Arrays.sort(lvjian2);
        Arrays.sort(lvjian3);
        guyu1 = (lvjian1[15] + lvjian2[14]) * 1.0 / 2;
        guyu2 = (lvjian2[15] +lvjian2[14]) * 1.0 / 2;
        guyu3 = (lvjian3[15] + lvjian3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + guyu1);
        System.out.println("农业设施设计与制造的中位数为:" + guyu2);
        System.out.println("园艺植物设施栽培学的中位数为:" + guyu3);





    }
}
